using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace SaveFileDialogBoxProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {                
                string filename;
                filename = saveFileDialog1.FileName;
                textBox1.Text = filename;
                StreamWriter sw = File.CreateText(filename);
                sw.Write(richTextBox1.Text);
                sw.Close();
            }
        }
    }
}